
let initState = {
    cartList:[]
}

function cartReducer(state=initState,action){
    switch(action.type){
        case "SET_CARTLIST":
            let mystate = JSON.parse(JSON.stringify(state));
            mystate.cartList = action.list;
            return mystate;
        case "SET_GOODS_NUM":
            let newState = JSON.parse(JSON.stringify(state));
            newState.cartList[action.index].cartNum = action.cartNum;
            return newState;
        default :
          return state;
    }
}


export default cartReducer;